<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
  <title>郑大地图</title>
  <link rel="stylesheet" href="https://a.amap.com/jsapi_demos/static/demo-center/css/demo-center.css" />
  <script src="https://cache.amap.com/lbs/static/es5.min.js"></script>
  <script src="https://webapi.amap.com/maps?v=2.0&key=53b4e246765e8898dc8ecfa7f7a543e5&&plugin=AMap.Scale,AMap.HawkEye,AMap.ToolBar,AMap.ControlBar"></script>

  <style>
    html, body {
      height: 100%;
    }
    #container {
      height: 100%;
    }
    .input-card {
      width: 150px;
      top: 20px;
      left: 20px;
      bottom: auto;
    }
    /*取消logo*/
    .BMap_cpyCtrl
    {
      display: none;
    }
    .anchorBL {
      display: none;
    }
    .amap-logo img{
      display: none;
    }
    .amap-copyright {
      opacity:0;
    }
  </style>
</head>
<body>
<div id="container"></div>
<div class='input-card'>
  <div class="input-item">
    <input type="checkbox" checked onclick="toggleScale(this)"/>比例尺
  </div>

  <div class="input-item">
    <input type="checkbox" checked id="toolbar" onclick="toggleToolBar(this)"/>工具条
  </div>

  <div class="input-item">
    <input type="checkbox" checked id="controlBar" onclick="toggleControlBar(this)"/>工具条方向盘
  </div>

  <div class="input-item">
    <input type="checkbox" checked id="overview" onclick="toggleOverViewShow(this)"/>显示鹰眼
  </div>

</div>
<script>
  var scale = new AMap.Scale(),
      toolBar = new AMap.ToolBar({
        position: {
          top: '110px',
          right: '40px'
        }
      }),
      controlBar = new AMap.ControlBar({
        position: {
          top: '10px',
          right: '10px',
        }
      }),
      overView = new AMap.HawkEye({
        opened: false
      }),
      map = new AMap.Map("container", {
        center:[113.53591,34.817077], // 郑州大学
        viewMode: '3D',
        zoom: 16,
        pitch: 30,
        isHotspot: true
      });
  map.addControl(scale);
  map.addControl(toolBar);
  map.addControl(controlBar);
  map.addControl(overView);
  function toggleScale(checkbox) {
    if (checkbox.checked) {
      scale.show();
    } else {
      scale.hide();
    }
  }
  function toggleToolBar(checkbox) {
    if (checkbox.checked) {
      showToolBar();
    } else {
      hideToolBar();
    }
  }
  function toggleControlBar(checkbox) {
    if (checkbox.checked) {
      controlBar.show()
    } else {
      controlBar.hide()
    }
  }
  function toggleOverViewShow(checkbox) {
    if (checkbox.checked) {
      overView.show();
    } else {
      overView.hide();
    }
  }

  function showToolBar() {
    document.getElementById('toolbar').checked = true;
    toolBar.show();
  }
  function hideToolBar() {
    document.getElementById('toolbar').checked = false;
    toolBar.hide();
  }
  function showControlBar() {
    document.getElementById('controlBar').checked = true;
    controlBar.show();
  }
  function hideControlBar() {
    document.getElementById('controlBar').checked = false;
    controlBar.hide();
  }

  //创建右键菜单
  var contextMenu = new AMap.ContextMenu();

  //右键放大
  contextMenu.addItem("放大一级", function () {
    map.zoomIn();
  }, 0);

  //右键缩小
  contextMenu.addItem("缩小一级", function () {
    map.zoomOut();
  }, 1);

  //右键显示全国范围
  contextMenu.addItem("缩放至全国范围", function (e) {
    map.setZoomAndCenter(4, [108.946609, 34.262324]);
  }, 2);

  //右键添加Marker标记
  contextMenu.addItem("添加标记", function (e) {
    var marker = new AMap.Marker({
      map: map,
      position: contextMenuPositon //基点位置
    });
  }, 3);

  //地图绑定鼠标右击事件——弹出右键菜单
  map.on('rightclick', function (e) {
    contextMenu.open(map, e.lnglat);
    contextMenuPositon = e.lnglat;
  });

  contextMenu.open(map, lnglat);
</script>
</body>
</html>